<?php

namespace App\Kuafu\User\Model;

use App\Kuafu\Base\Model\BaseModel;
use App\Kuafu\Base\Model\Traits\KfSoftDeletes;
use App\Kuafu\Common\Enum\CodeEnum;

class Permissions extends BaseModel
{
    use KfSoftDeletes;

    protected $hidden = ['isDeleted', 'updatedAt', 'createdAt', 'status', 'locate', 'createdByUid', 'updatedByUid'];

    public static function getAll($platform = CodeEnum::PLATFORM_DEFAULT)
    {
        $data = self::query()
                    ->when($platform != CodeEnum::PLATFORM_DEFAULT, function ($query) use ($platform) {
                        $query->where('platform', $platform);
                    })
                    ->get();
        return $data;
    }

    public static function getAllByIds(array $ids, int $platform = CodeEnum::PLATFORM_DEFAULT)
    {
        $data = self::query()
                    ->when($platform != CodeEnum::PLATFORM_DEFAULT, function ($query) use ($platform) {
                        $query->where('platform', $platform);
                    })
                    ->whereIn('id', $ids)
                    ->get();
        return $data;

    }

}
